import fs from 'fs';

const readStream = fs.createReadStream('./aaa.txt', {
    start: 8, // 从字节位置8开始读取
    end: 22, // 读取到字节位置22结束（包括22）
    highWaterMark: 3 // 每次读取3个字节
    });

readStream.on('data', (data) => {
    console.log(data.toString());
        });

readStream.on('open', (fd) => {
    console.log('通过流将⽂件打开~', fd);
    });

readStream.on('end', () => {
    console.log('已经读取到end位置');
        });

readStream.on('close', () => {
    console.log('⽂件读取结束, 并且被关闭');
     });